//
//  InforDetailViewController.m
//  NhomThuy02
//
//  Created by Dat on 2/3/15.
//  Copyright (c) 2015 LamQuoc. All rights reserved.
//

#import "InforDetailViewController.h"

@interface InforDetailViewController ()<UIScrollViewDelegate>

@end

@implementation InforDetailViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}
- (void)viewDidLayoutSubviews{
    
}
- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
    self.myImageScrollView.delegate = self;
    
    float totalWidth = 0;
    
    NSArray *Images = [[NSArray alloc]initWithObjects:@"Thuy.jpg",@"Hien.jpg",@"Dung.jpg",@"Chuong.jpg",@"Quoc.jpg",@"Dat.jpg", nil];
    _myArray = [[NSArray alloc]initWithObjects:@"Pe Thuy",@"Hien Tran",@"Huynh Tri Dung",@"Thien Chuong",@"Lam Quoc",@"Dat Tran", nil];
    
    for (int i=0; i<Images.count; i++) {
        CGRect myFrameImage = CGRectMake(totalWidth, 0, self.myImageScrollView.frame.size.width, self.myImageScrollView.frame.size.height);
        UIImage *image = [UIImage imageNamed:[Images objectAtIndex:i]];
        UIImageView *imageView = [[UIImageView alloc]initWithFrame:myFrameImage];
        imageView.image = image;
        [self.myImageScrollView addSubview:imageView];
        totalWidth = totalWidth + myFrameImage.size.width;
    CGSize mySize = CGSizeMake(totalWidth,self.myImageScrollView.frame.size.height);
    
        [self.myImageScrollView setContentSize:mySize];
        [self.myImageScrollView setScrollEnabled:true];
        [self.myImageScrollView setPagingEnabled:true];
        [self.myPageControll setNumberOfPages:6];
        self.myInforLable.text = _myArray[0];
        
    }
    
        
    
};

- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    CGPoint offset = scrollView.contentOffset;
    int currentpage = ((int)offset.x / self.myImageScrollView.frame.size.width);
    [self.myPageControll setCurrentPage:currentpage];
    self.myInforLable.text = self.myArray[currentpage];
}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
